<?php


namespace app\api\model;

use think\Model;

/**
 * 主播分类
 * Class CategoryModel
 * @package app\api\model
 */
class CategoryModel extends Model
{

    /**
     * 设置表名
     * @var string
     */
    protected $table = 'te_category';

    /**
     *
     * 主播分类信息
     *
     */
    public static function cateList(){

        $where = ['status'=>1,'is_deleted'=>0];
        $field = 'id,name';
        return self::where($where)
            ->where(['pid'=>0])
            ->field($field)
            ->order('id desc')
            ->select()->each(function ($item)use ($where,$field){

                $item['child_cate'] = self::where($where)
                    ->where(['pid'=>$item['id']])
                    ->field($field)
                    ->select();
            });
    }
}